package com.saascloud.redis.core;

import com.saascloud.thread.ThreadTaskUtils;

import java.util.Objects;

/**
 * @Author: liangxu
 * @Contact: one_dream@aliyun.com
 * @Date: 2022/6/2 8:25
 * @Version: 1.0
 * @Description: 用户设置缓存是否需要忽略租户id，默认不忽略，设置为true时忽略，目前只有在幂等校验时才会设置为true
 */
public class TenantIgnore {
    private static ThreadLocal<Boolean> ignoreLocal = ThreadTaskUtils.newThreadLocal();

    public static void setIgnore(Boolean ignore) {
        ignoreLocal.set(ignore);
    }

    public static Boolean getIgnore() {
        Boolean ignore = ignoreLocal.get();
        return Objects.isNull(ignore) ? false : ignore;
    }

    public static void remove() {
        ignoreLocal.remove();
    }
}
